package com.zhuo.project.hms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhuo.framework.aspectj.lang.annotation.Log;
import com.zhuo.framework.aspectj.lang.enums.BusinessType;
import com.zhuo.project.hms.domain.ZzClinic;
import com.zhuo.project.hms.service.IZzClinicService;
import com.zhuo.framework.web.controller.BaseController;
import com.zhuo.framework.web.domain.AjaxResult;
import com.zhuo.common.utils.poi.ExcelUtil;
import com.zhuo.framework.web.page.TableDataInfo;

/**
 * 诊所信息Controller
 * 
 * @author zhuo
 * @date 2020-03-20
 */
@RestController
@RequestMapping("/hms/clinic")
public class ZzClinicController extends BaseController
{
    @Autowired
    private IZzClinicService zzClinicService;

    /**
     * 查询诊所信息列表
     */
    @PreAuthorize("@ss.hasPermi('hms:clinic:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZzClinic zzClinic)
    {
        startPage();
        List<ZzClinic> list = zzClinicService.selectZzClinicList(zzClinic);
        return getDataTable(list);
    }

    /**
     * 导出诊所信息列表
     */
    @PreAuthorize("@ss.hasPermi('hms:clinic:export')")
    @Log(title = "诊所信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZzClinic zzClinic)
    {
        List<ZzClinic> list = zzClinicService.selectZzClinicList(zzClinic);
        ExcelUtil<ZzClinic> util = new ExcelUtil<ZzClinic>(ZzClinic.class);
        return util.exportExcel(list, "clinic");
    }

    /**
     * 获取诊所信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('hms:clinic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zzClinicService.selectZzClinicById(id));
    }

    /**
     * 新增诊所信息
     */
    @PreAuthorize("@ss.hasPermi('hms:clinic:add')")
    @Log(title = "诊所信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZzClinic zzClinic)
    {
        return toAjax(zzClinicService.insertZzClinic(zzClinic));
    }

    /**
     * 修改诊所信息
     */
    @PreAuthorize("@ss.hasPermi('hms:clinic:edit')")
    @Log(title = "诊所信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZzClinic zzClinic)
    {
        return toAjax(zzClinicService.updateZzClinic(zzClinic));
    }

    /**
     * 删除诊所信息
     */
    @PreAuthorize("@ss.hasPermi('hms:clinic:remove')")
    @Log(title = "诊所信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zzClinicService.deleteZzClinicByIds(ids));
    }
}
